// 引入request
import request from '../util/request.js';

const FlawRequest = {
    BASE_URL : "http://localhost:8086/qc",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询dict列表
     * @param flaw
     * @param callBack
     */
    loadFlaw(flaw, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/flaw/queryByPage";
        // 调用request进行请求  http://lcation
        request.get(url,flaw,callBack);
    },
    /**
     * 查询所有信息
     */
    loadFlawAll(callBack){
        let url = this.BASE_URL + "/flaw/queryAll";
        request.get(url,null,callBack);
    },

    /**
     * 新增字典的API
     * @param flaw
     * @param callBack
     */
    addFlaw(flaw,callBack){
        let url = this.BASE_URL + "/flaw/save"
        request.post(url,flaw,callBack);
    },
    /**
     * 通过id加载字典信息的API
     * @param flaw
     * @param callBack
     */
    getByDescription(flawDescription,callBack){
        let url = this.BASE_URL + "/flaw/queryByDescription?flawDescription=" + flawDescription;
        request.get(url,null,callBack);
    }
    ,
    /**
     * 修改字典信息的API
     * @param flaw
     * @param callBack
     */
    updateFalw(flaw,callBack){
        let url = this.BASE_URL + "/flaw/update";
        request.post(url,flaw,callBack);
    },
    /**
     *  删除字典的API
     * @param dictId
     * @param callBack
     */
    deleteFlaw(flawDescription,callBack){
        request.get(this.BASE_URL + "/flaw/delete?flawDescription=" + flawDescription,null,callBack);
    },
    /**
     * 批量删除字典的API
     * @param dictIds
     * @param callBack
     */
    deleteFlaws(flawDescriptions,callBack){
        let url = this.BASE_URL + "/flaw/deletes?a=1";
        for (let i = 0; i < flawDescriptions.length; i++){
            url += "&flawDescriptions="+flawDescriptions[i];
        }
        request.get(url,null,callBack);
    }
}
// 导出我们申明的dictrequest对象
export default FlawRequest;